const customRequst = require('../../../common/customRequst');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: [],
    page: 1,
    pagesize: 15,
    isLoadAll: false,
  },
  onLoad: function (options) {

  },
  onShow: function () {
    let that = this;
    that.onLoadList();
  },

  //触底加载
  scrollSearchList: function () {
    let that = this;
    if (that.data.isLoadAll) {
      return;
    }
    that.setData({
      page: parseInt(that.data.page) + 1
    });
    that.onLoadList();
  },

  onLoadList: function () {
    let that = this;
    if (that.data.isLoadAll) {
      return;
    }
    customRequst.postRequest('api/groups/profitlog', {
      page: that.data.page,
      pagesize: that.data.pagesize
    }).then(function (re) {
      if (re.code == 1) {
        if(re.data.length <= 0){
          that.setData({
            isLoadAll:true
          });
          return;
        }
        let list = that.data.list;
        for (let i in re.data) {
          list.push(re.data[i]);
        }
        that.setData({
          list: list
        });
      } else {

      }
    })
  }

})